package com.vito.demo.sb2.business.services

import com.vito.demo.sb2.business.daos.NewsDao
import com.vito.demo.sb2.business.entities.News
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

/**
 * Created by lingzhiyuan.
 * Date : 16/3/31.
 * Time : 下午6:51.
 * Description:
 *
 */

@Service
@Transactional
open class NewsService @Autowired constructor(var newsDao: NewsDao) {

    open fun findAllNews() = newsDao.findAll(News::class.java)

    open fun save(title: String, content: String): Boolean {

        var news = News()
        news.title = title
        news.content = content
        newsDao.saveOrUpdate(news)
        return true
    }

}